<?php
session_start();
include("config.php");
//  include config.php for DB queries
$results = mysql_query("SELECT * FROM admin_settings");

while ($row = mysql_fetch_array($results)) {
	$rss_tab_1_address = $row["rss_tab_1_address"];
	$rss_tab_1_title = $row["rss_tab_1_title"];
	$rss_tab_2_address = $row["rss_tab_2_address"];
	$rss_tab_2_title = $row["rss_tab_2_title"];
	$num_rss_display = $row["num_rss_display"];
	$meta_ip_address = $row["meta_ip_address"];
}
?>
<script type="text/javascript">

function update_global_admin(table,column,value) {
        var url='pages/query.php?';
        url=url+'&cmd=admin_settings_update';
	url=url+'&table='+table;
	url=url+'&column='+column;
	url=url+'&value='+escape(value);
	url=url+'&sid='+Math.random();
        
        //Send the data to the query.php script to update the DB
        var myRequest = new Request({
                url: url, 
                onSuccess: function(response) {
                                //TODO:  Put a green OK or red FAIL next to the update button on success or fail
				//alert(response);
                } 
        }).send();
}

</script>

<table width="100%" class="results">
	<tr><th colspan="2">General Settings</th></tr>
	<tr><td width="20%">RSS Tab 1 Address:</td><td width="80%">
		<form>
		<input name="rss_tab_1_address" type="text" value="<?php echo $rss_tab_1_address ?>"></input>
		<input type="button" value="Update" onClick="update_global_admin('admin_settings','rss_tab_1_address',this.form.rss_tab_1_address.value)"></input>
		</form>
	    </td>
	</tr>
	<tr><td width="20%">RSS Tab 1 Title:</td><td width="80%">
		<form>
		<input name="rss_tab_1_title" type="text" value="<?php echo $rss_tab_1_title ?>"></input>
		<input type="button" value="Update" onClick="update_global_admin('admin_settings','rss_tab_1_title',this.form.rss_tab_1_title.value)"></input>
		</form>
	    </td>
	</tr>
	<tr><td width="20%">RSS Tab 2:</td><td width="80%">
		<form>
		<input name="rss_tab_2_address" type="text" value="<?php echo $rss_tab_2_address ?>"></input>
		<input type="button" value="Update" onClick="update_global_admin('admin_settings', 'rss_tab_2_address', this.form.rss_tab_2_address.value)"></input>
		</form>
	    </td>
	</tr>
	<tr><td width="20%">RSS Tab 2 Title:</td><td width="80%">
		<form>
		<input name="rss_tab_2_title" type="text" value="<?php echo $rss_tab_2_title ?>"></input>
		<input type="button" value="Update" onClick="update_global_admin('admin_settings','rss_tab_2_title',this.form.rss_tab_2_title.value)"></input>
		</form>
	    </td>
	</tr>
	<tr><td width="20%">Number of RSS item to display:</td><td width="80%">
		<form>
		<input name="num_rss_display" type="text" value="<?php echo $num_rss_display ?>"></input>
		<input type="button" value="Update" onClick="update_global_admin('admin_settings', 'num_rss_display', this.form.num_rss_display.value)"></input>
		</form>
	    </td>
	</tr>
	<tr><td width="20%">Metaswitch IP Address:</td><td width="80%">
		<form>
		<input name="meta_ip_address" type="text" value="<?php echo $meta_ip_address ?>"></input>
		<input type="button" value="Update" onClick="update_global_admin('admin_settings', 'meta_ip_address', this.form.meta_ip_address.value)"></input>
		</form>
	    </td>
	</tr>
</table>

**  Refresh your page for the settings to take effect  **
